from math import pi
from os.path import dirname
from PyQt5.uic import loadUi
from PyQt5.QtGui import QPixmap
from PyQt5.QtWidgets import QMainWindow, QMessageBox, QApplication

cao = [['5', '50', '37', '4.5', '7', '7', '3.5'], ['6.3', '63', '40', '4.8', '7.5', '7.5', '3.8'],
       ['6.5', '65', '40', '4.3', '7.5', '7.5', '3.8'], ['8', '80', '43', '5', '8', '8', '4'],
       ['10', '100', '48', '5.3', '8.5', '8.5', '4.25'], ['12', '120', '53', '5.5', '9', '9', '4.5'],
       ['12.6', '126', '53', '5.5', '9', '9', '4.5'], ['14a', '140', '58', '6', '9.5', '9.5', '4.8'],
       ['14b', '140', '60', '8', '9.5', '9.5', '4.8'], ['16a', '160', '63', '6.5', '10', '10', '5'],
       ['16b', '160', '65', '8.5', '10', '10', '5'], ['18a', '180', '68', '7', '10.5', '10.5', '5.2'],
       ['18b', '180', '70', '9', '10.5', '10.5', '5.2'], ['20a', '200', '73', '7', '11', '11', '5.5'],
       ['20b', '200', '75', '9', '11', '11', '5.5'], ['22a', '220', '77', '7', '11.5', '11.5', '5.8'],
       ['22b', '220', '79', '9', '11.5', '11.5', '5.8'], ['24a', '240', '78', '7', '12', '12', '6'],
       ['24b', '240', '80', '9', '12', '12', '6'], ['24c', '240', '82', '11', '12', '12', '6'],
       ['25a', '250', '78', '7', '12', '12', '6'], ['25b', '250', '80', '9', '12', '12', '6'],
       ['25c', '250', '82', '11', '12', '12', '6'], ['27a', '270', '82', '7.5', '12.5', '12.5', '6.2'],
       ['27b', '270', '84', '9.5', '12.5', '12.5', '6.2'], ['27c', '270', '86', '11.5', '12.5', '12.5', '6.2'],
       ['28a', '280', '82', '7.5', '12.5', '12.5', '6.2'], ['28b', '280', '84', '9.5', '12.5', '12.5', '6.2'],
       ['28c', '280', '86', '11.5', '12.5', '12.5', '6.2'], ['30a', '300', '85', '7.5', '13.5', '13.5', '6.8'],
       ['30b', '300', '87', '9.5', '13.5', '13.5', '6.8'], ['30c', '300', '89', '11.5', '13.5', '13.5', '6.8'],
       ['32a', '320', '88', '8', '14', '14', '7'], ['32b', '320', '90', '10', '14', '14', '7'],
       ['32c', '320', '92', '12', '14', '14', '7'], ['36a', '360', '96', '9', '16', '16', '8'],
       ['36b', '360', '98', '11', '16', '16', '8'], ['36c', '360', '100', '13', '16', '16', '8'],
       ['40a', '400', '100', '10.5', '18', '18', '9'], ['40b', '400', '102', '12.5', '18', '18', '9'],
       ['40c', '400', '104', '14.5', '18', '18', '9']]

gong = [['10', '100', '68', '4.5', '7.6', '6.5', '3.3'], ['12', '120', '74', '5', '8.4', '7', '3.5'],
        ['12.6', '126', '74', '5', '8.4', '7', '3.5'], ['14', '140', '80', '5.5', '9.1', '7.5', '3.8'],
        ['16', '160', '88', '6', '9.9', '8', '4'], ['18', '180', '94', '6.5', '10.7', '8.5', '4.3'],
        ['20a', '200', '100', '7', '11.4', '9', '4.5'], ['20b', '200', '102', '9', '11.4', '9', '4.5'],
        ['22a', '220', '110', '7.5', '12.3', '9.5', '4.8'], ['22b', '220', '112', '9.5', '12.3', '9.5', '4.8'],
        ['24a', '240', '116', '8', '13', '10', '5'], ['24b', '240', '118', '10', '13', '10', '5'],
        ['25a', '250', '116', '8', '13', '10', '5'], ['25b', '250', '118', '10', '13', '10', '5'],
        ['27a', '270', '122', '8.5', '13.7', '10.5', '5.3'], ['27b', '270', '124', '10.5', '13.7', '10.5', '5.3'],
        ['28a', '280', '122', '8.5', '13.7', '10.5', '5.3'], ['28b', '280', '124', '10.5', '13.7', '10.5', '5.3'],
        ['30a', '300', '126', '9', '14.4', '11', '5.5'], ['30b', '300', '128', '11', '14.4', '11', '5.5'],
        ['30c', '300', '130', '13', '14.4', '11', '5.5'], ['32a', '320', '130', '9.5', '15', '11.5', '5.8'],
        ['32b', '320', '132', '11.5', '15', '11.5', '5.8'], ['32c', '320', '134', '13.5', '15', '11.5', '5.8'],
        ['36a', '360', '136', '10', '15.8', '12', '6'], ['36b', '360', '138', '12', '15.8', '12', '6'],
        ['36c', '360', '140', '14', '15.8', '12', '6'], ['40a', '400', '142', '10.5', '16.5', '12.5', '6.3'],
        ['40b', '400', '144', '12.5', '16.5', '12.5', '6.3'], ['40c', '400', '146', '14.5', '16.5', '12.5', '6.3'],
        ['45a', '450', '150', '11.5', '18', '13.5', '6.8'], ['45b', '450', '152', '13.5', '18', '13.5', '6.8'],
        ['45c', '450', '154', '15.5', '18', '13.5', '6.8'], ['50a', '500', '158', '12', '20', '14', '7'],
        ['50b', '500', '160', '14', '20', '14', '7'], ['50c', '500', '162', '16', '20', '14', '7'],
        ['55a', '550', '166', '12.5', '21', '14.5', '7.3'], ['55b', '550', '168', '14.5', '21', '14.5', '7.3'],
        ['55c', '550', '170', '16.5', '21', '14.5', '7.3'], ['56a', '560', '166', '12.5', '21', '14.5', '7.3'],
        ['56b', '560', '168', '14.5', '21', '14.5', '7.3'], ['56c', '560', '170', '16.5', '21', '14.5', '7.3'],
        ['63a', '630', '176', '13', '22', '15', '7.5'], ['63b', '630', '178', '15', '22', '15', '7.5'],
        ['63c', '630', '180', '17', '22', '15', '7.5']]

H = [['95*48', '95', '48', '3.2', '4.5', '8'], ['96*99', '96', '99', '4.5', '6', '8'],
     ['97*49', '97', '49', '4', '5.5', '8'], ['100*50', '100', '50', '5', '7', '8'],
     ['100*100', '100', '100', '6', '8', '8'], ['118*58', '118', '58', '3.2', '4.5', '8'],
     ['119*123', '119', '123', '4.5', '6', '8'], ['120*59', '120', '59', '4', '5.5', '8'],
     ['125*60', '125', '60', '6', '8', '8'], ['125*125', '125', '125', '6.5', '9', '8'],
     ['139*97', '139', '97', '3.2', '4.5', '8'], ['142*99', '142', '99', '4.5', '6', '8'],
     ['144*148', '144', '148', '5', '7', '8'], ['145*73', '145', '73', '3.2', '4.5', '8'],
     ['147*74', '147', '74', '4', '5.5', '8'], ['147*149', '147', '149', '6', '8.5', '8'],
     ['148*100', '148', '100', '6', '9', '8'], ['150*75', '150', '75', '5', '7', '8'],
     ['150*150', '150', '150', '7', '10', '8'], ['167*173', '167', '173', '5', '7', '13'],
     ['168*88', '168', '88', '3.2', '4.5', '8'], ['171*89', '171', '89', '4', '6', '8'],
     ['172*175', '172', '175', '6.5', '9.5', '13'], ['175*90', '175', '90', '5', '8', '8'],
     ['175*175', '175', '175', '7.5', '11', '13'], ['188*149', '188', '149', '4.5', '6', '8'],
     ['192*198', '192', '198', '6', '8', '13'], ['193*98', '193', '98', '3.2', '4.5', '8'],
     ['194*150', '194', '150', '6', '9', '8'], ['196*99', '196', '99', '4', '6', '8'],
     ['198*99', '198', '99', '4.5', '7', '8'], ['200*100', '200', '100', '5.5', '8', '8'],
     ['200*200', '200', '200', '8', '12', '13'], ['200*204', '200', '204', '12', '12', '13'],
     ['238*173', '238', '173', '4.5', '8', '13'], ['244*124', '244', '124', '4.5', '6', '8'],
     ['244*175', '244', '175', '7', '11', '13'], ['244*252', '244', '252', '11', '11', '13'],
     ['248*124', '248', '124', '5', '8', '8'], ['250*125', '250', '125', '6', '9', '8'],
     ['250*250', '250', '250', '9', '14', '13'], ['250*255', '250', '255', '14', '14', '13'],
     ['286*198', '286', '198', '6', '8', '13'], ['294*148', '294', '148', '4.5', '6', '13'],
     ['294*200', '294', '200', '8', '12', '13'], ['294*302', '294', '302', '12', '12', '13'],
     ['298*149', '298', '149', '5.5', '8', '13'], ['298*201', '298', '201', '9', '14', '13'],
     ['300*150', '300', '150', '6.5', '9', '13'], ['300*300', '300', '300', '10', '15', '13'],
     ['300*305', '300', '305', '15', '15', '13'], ['338*351', '338', '351', '13', '13', '13'],
     ['340*173', '340', '173', '4.5', '6', '13'], ['340*250', '340', '250', '9', '14', '13'],
     ['344*348', '344', '348', '10', '16', '13'], ['344*354', '344', '354', '16', '16', '13'],
     ['346*174', '346', '174', '6', '9', '13'], ['350*175', '350', '175', '7', '11', '13'],
     ['350*350', '350', '350', '12', '19', '13'], ['350*357', '350', '357', '19', '19', '13'],
     ['388*402', '388', '402', '15', '15', '22'], ['390*148', '390', '148', '6', '8', '13'],
     ['390*198', '390', '198', '6', '8', '13'], ['390*300', '390', '300', '10', '16', '13'],
     ['394*398', '394', '398', '11', '18', '22'], ['394*405', '394', '405', '18', '18', '22'],
     ['396*199', '396', '199', '7', '11', '13'], ['400*150', '400', '150', '8', '13', '13'],
     ['400*200', '400', '200', '8', '13', '13'], ['400*400', '400', '400', '13', '21', '22'],
     ['400*408', '400', '408', '21', '21', '22'], ['414*405', '414', '405', '18', '28', '22'],
     ['428*407', '428', '407', '20', '35', '22'], ['440*300', '440', '300', '11', '18', '13'],
     ['446*150', '446', '150', '7', '12', '13'], ['446*199', '446', '199', '8', '12', '13'],
     ['450*151', '450', '151', '8', '14', '13'], ['450*200', '450', '200', '9', '14', '13'],
     ['458*417', '458', '417', '30', '50', '22'], ['470*150', '470', '150', '7', '13', '13'],
     ['475*151.5', '475', '151.5', '8.5', '15.5', '13'], ['482*153.5', '482', '153.5', '10.5', '19', '13'],
     ['482*300', '482', '300', '11', '15', '13'], ['488*300', '488', '300', '11', '18', '13'],
     ['492*150', '492', '150', '7', '12', '13'], ['492*465', '492', '465', '15', '20', '22'],
     ['496*199', '496', '199', '9', '14', '13'], ['498*432', '498', '432', '45', '70', '22'],
     ['500*152', '500', '152', '9', '16', '13'], ['500*200', '500', '200', '10', '16', '13'],
     ['502*465', '502', '465', '15', '25', '22'], ['502*470', '502', '470', '20', '25', '22'],
     ['504*153', '504', '153', '10', '18', '13'], ['506*201', '506', '201', '11', '19', '13'],
     ['544*300', '544', '300', '11', '15', '13'], ['546*199', '546', '199', '9', '14', '13'],
     ['550*200', '550', '200', '10', '16', '13'], ['550*300', '550', '300', '11', '18', '13'],
     ['582*300', '582', '300', '12', '17', '13'], ['588*300', '588', '300', '12', '20', '13'],
     ['594*302', '594', '302', '14', '23', '13'], ['596*199', '596', '199', '10', '15', '13'],
     ['600*200', '600', '200', '11', '17', '13'], ['606*201', '606', '201', '12', '20', '13'],
     ['625*198.5', '625', '198.5', '13.5', '17.5', '13'], ['630*200', '630', '200', '15', '20', '13'],
     ['638*202', '638', '202', '17', '24', '13'], ['646*299', '646', '299', '12', '18', '18'],
     ['650*300', '650', '300', '13', '20', '18'], ['654*301', '654', '301', '14', '22', '18'],
     ['692*300', '692', '300', '13', '20', '18'], ['700*300', '700', '300', '13', '24', '18'],
     ['734*299', '734', '299', '12', '16', '18'], ['742*300', '742', '300', '13', '20', '18'],
     ['750*300', '750', '300', '13', '24', '18'], ['758*303', '758', '303', '16', '28', '18'],
     ['792*300', '792', '300', '14', '22', '18'], ['800*300', '800', '300', '14', '26', '18'],
     ['834*298', '834', '298', '14', '19', '18'], ['842*299', '842', '299', '15', '23', '18'],
     ['850*300', '850', '300', '16', '27', '18'], ['858*301', '858', '301', '17', '31', '18'],
     ['890*299', '890', '299', '15', '23', '18'], ['900*300', '900', '300', '16', '28', '18'],
     ['912*302', '912', '302', '18', '34', '18'], ['970*297', '970', '297', '16', '21', '18'],
     ['980*298', '980', '298', '17', '26', '18'], ['990*298', '990', '298', '17', '31', '18'],
     ['1000*300', '1000', '300', '19', '36', '18'], ['1008*302', '1008', '302', '21', '40', '18']]

ban = [[str(_) + 'mm', str(_)] for _ in range(3, 50)]

jin = [['Φ' + str(_) + 'mm', str(_)] for _ in range(3, 50)]

deng = [['∟20*20*3', '20', '3', '3.5', '1.004351'], ['∟20*20*4', '20', '4', '3.5', '1.306291'],
        ['∟25*25*3', '25', '3', '3.5', '1.004351'], ['∟25*25*4', '25', '4', '3.5', '1.306291'],
        ['∟30*30*3', '30', '3', '4.5', '1.027245'], ['∟30*30*4', '30', '4', '4.5', '1.323974'],
        ['∟36*36*3', '36', '3', '4.5', '1.027245'], ['∟36*36*4', '36', '4', '4.5', '1.323974'],
        ['∟36*36*5', '36', '5', '4.5', '1.638029'], ['∟40*40*3', '40', '3', '5', '1.051024'],
        ['∟40*40*4', '40', '4', '5', '1.342507'], ['∟40*40*5', '40', '5', '5', '1.653045'],
        ['∟45*45*3', '45', '3', '5', '1.051024'], ['∟45*45*4', '45', '4', '5', '1.342507'],
        ['∟45*45*5', '45', '5', '5', '1.653045'], ['∟45*45*6', '45', '6', '5', '1.973664'],
        ['∟50*50*3', '50', '3', '5.5', '0.968996'], ['∟50*50*4', '50', '4', '5.5', '1.367182'],
        ['∟50*50*5', '50', '5', '5.5', '1.673146'], ['∟50*50*6', '50', '6', '5.5', '1.990530'],
        ['∟56*56*3', '56', '3', '6', '1.011561'], ['∟56*56*4', '56', '4', '6', '1.311842'],
        ['∟56*56*5', '56', '5', '6', '1.698152'], ['∟56*56*6', '56', '6', '6', '2.011594'],
        ['∟56*56*7', '56', '7', '6', '2.332780'], ['∟56*56*8', '56', '8', '6', '2.658903'],
        ['∟60*60*5', '60', '5', '6.5', '1.659189'], ['∟60*60*6', '60', '6', '6.5', '1.978812'],
        ['∟60*60*7', '60', '7', '6.5', '2.354486'], ['∟60*60*8', '60', '8', '6.5', '2.677968'],
        ['∟63*63*4', '63', '4', '7', '1.307403'], ['∟63*63*5', '63', '5', '7', '1.694725'],
        ['∟63*63*6', '63', '6', '7', '2.008702'], ['∟63*63*7', '63', '7', '7', '2.330286'],
        ['∟63*63*8', '63', '8', '7', '2.656716'], ['∟63*63*10', '63', '10', '7', '3.247539'],
        ['∟70*70*4', '70', '4', '8', '1.329452'], ['∟70*70*5', '70', '5', '8', '1.642460'],
        ['∟70*70*6', '70', '6', '8', '2.023122'], ['∟70*70*7', '70', '7', '8', '2.342727'],
        ['∟70*70*8', '70', '8', '8', '2.533497'], ['∟75*75*5', '75', '5', '9', '1.680947'],
        ['∟75*75*6', '75', '6', '9', '1.997091'], ['∟75*75*7', '75', '7', '9', '2.369869'],
        ['∟75*75*8', '75', '8', '9', '2.691503'], ['∟75*75*9', '75', '9', '9', '2.818131'],
        ['∟75*75*10', '75', '10', '9', '3.204285'], ['∟80*80*5', '80', '5', '9', '1.680947'],
        ['∟80*80*6', '80', '6', '9', '1.997091'], ['∟80*80*7', '80', '7', '9', '2.369869'],
        ['∟80*80*8', '80', '8', '9', '2.818131'], ['∟80*80*9', '80', '9', '9', '2.818131'],
        ['∟80*80*10', '80', '10', '9', '3.204285'], ['∟90*90*6', '90', '6', '10', '1.867718'],
        ['∟90*90*7', '90', '7', '10', '2.411214'], ['∟90*90*8', '90', '8', '10', '2.852987'],
        ['∟90*90*9', '90', '9', '10', '2.852987'], ['∟90*90*10', '90', '10', '10', '3.234983'],
        ['∟90*90*12', '90', '12', '10', '3.887966'], ['∟100*100*6', '100', '6', '12', '2.134980'],
        ['∟100*100*7', '100', '7', '12', '2.134980'], ['∟100*100*8', '100', '8', '12', '2.623685'],
        ['∟100*100*9', '100', '9', '12', '3.034683'], ['∟100*100*10', '100', '10', '12', '3.396304'],
        ['∟100*100*12', '100', '12', '12', '4.023189'], ['∟100*100*14', '100', '14', '12', '4.564779'],
        ['∟100*100*16', '100', '16', '12', '5.273894'], ['∟110*110*7', '110', '7', '12', '2.134980'],
        ['∟110*110*8', '110', '8', '12', '2.623685'], ['∟110*110*10', '110', '10', '12', '3.396304'],
        ['∟110*110*12', '110', '12', '12', '4.023189'], ['∟110*110*14', '110', '14', '12', '4.564779'],
        ['∟125*125*8', '125', '8', '14', '2.702282'], ['∟125*125*10', '125', '10', '14', '3.457382'],
        ['∟125*125*12', '125', '12', '14', '4.074881'], ['∟125*125*14', '125', '14', '14', '4.610403'],
        ['∟125*125*16', '125', '16', '14', '5.313432'], ['∟140*140*10', '140', '10', '14', '3.457382'],
        ['∟140*140*12', '140', '12', '14', '4.074881'], ['∟140*140*14', '140', '14', '14', '8.232098'],
        ['∟140*140*16', '140', '16', '14', '5.313432'], ['∟150*150*8', '150', '8', '14', '2.702282'],
        ['∟150*150*10', '150', '10', '14', '3.457382'], ['∟150*150*12', '150', '12', '14', '4.074881'],
        ['∟150*150*14', '150', '14', '14', '4.610403'], ['∟150*150*15', '150', '15', '14', '5.089890'],
        ['∟150*150*16', '150', '16', '14', '5.313432'], ['∟160*160*10', '160', '10', '16', '3.423584'],
        ['∟160*160*12', '160', '12', '16', '4.046244'], ['∟160*160*14', '160', '14', '16', '4.585112'],
        ['∟160*160*16', '160', '16', '16', '5.291503'], ['∟180*180*12', '180', '12', '16', '4.046244'],
        ['∟180*180*14', '180', '14', '16', '4.585112'], ['∟180*180*16', '180', '16', '16', '5.291503'],
        ['∟180*180*18', '180', '18', '16', '5.914114'], ['∟200*200*14', '200', '14', '18', '4.739738'],
        ['∟200*200*16', '200', '16', '18', '5.426035'], ['∟200*200*18', '200', '18', '18', '6.034783'],
        ['∟200*200*20', '200', '20', '18', '6.587515'], ['∟200*200*24', '200', '24', '18', '8.020323'],
        ['∟220*220*16', '220', '16', '21', '5.241826'], ['∟220*220*18', '220', '18', '21', '6.064575'],
        ['∟220*220*20', '220', '20', '21', '6.614818'], ['∟220*220*22', '220', '22', '21', '7.284102'],
        ['∟220*220*24', '220', '24', '21', '8.186063'], ['∟220*220*26', '220', '26', '21', '8.186063'],
        ['∟250*250*18', '250', '18', '24', '6.069366'], ['∟250*250*20', '250', '20', '24', '6.619211'],
        ['∟250*250*22', '250', '22', '24', '6.792609'], ['∟250*250*24', '250', '24', '24', '8.046377'],
        ['∟250*250*26', '250', '26', '24', '8.046377'], ['∟250*250*28', '250', '28', '24', '9.625547'],
        ['∟250*250*30', '250', '30', '24', '10.097202'], ['∟250*250*32', '250', '32', '24', '10.766010'],
        ['∟250*250*35', '250', '35', '24', '11.697744']]

bu = [['∟25*16*3', '25', '16', '3', '3.5', '1.004351'], ['∟25*16*4', '25', '16', '4', '3.5', '1.306291'],
      ['∟32*20*3', '32', '20', '3', '3.5', '1.004351'], ['∟32*20*4', '32', '20', '4', '3.5', '1.306291'],
      ['∟40*25*3', '40', '25', '3', '4', '1.011561'], ['∟40*25*4', '40', '25', '4', '4', '1.311842'],
      ['∟45*28*3', '45', '28', '3', '5', '1.051024'], ['∟45*28*4', '45', '28', '4', '5', '1.342507'],
      ['∟50*32*3', '50', '32', '3', '5.5', '0.968996'], ['∟50*32*4', '50', '32', '4', '5.5', '1.367182'],
      ['∟56*36*3', '56', '36', '3', '6', '1.011561'], ['∟56*36*4', '56', '36', '4', '6', '1.311842'],
      ['∟56*36*5', '56', '36', '5', '6', '1.698152'], ['∟63*40*4', '63', '40', '4', '7', '1.307403'],
      ['∟63*40*5', '63', '40', '5', '7', '1.694725'], ['∟63*40*6', '63', '40', '6', '7', '2.008702'],
      ['∟63*40*7', '63', '40', '7', '7', '2.330286'], ['∟70*45*4', '70', '45', '4', '7.5', '1.358650'],
      ['∟70*45*5', '70', '45', '5', '7.5', '1.666182'], ['∟70*45*6', '70', '45', '6', '7.5', '1.984680'],
      ['∟70*45*7', '70', '45', '7', '7.5', '2.309611'], ['∟75*50*5', '75', '50', '5', '8', '1.642460'],
      ['∟75*50*6', '75', '50', '6', '8', '2.023122'], ['∟75*50*8', '75', '50', '8', '8', '2.667635'],
      ['∟75*50*10', '75', '50', '10', '8', '3.327126'], ['∟80*50*5', '80', '50', '5', '8', '1.711792'],
      ['∟80*50*6', '80', '50', '6', '8', '2.023122'], ['∟80*50*7', '80', '50', '7', '8', '2.342727'],
      ['∟80*50*8', '80', '50', '8', '8', '2.667635'], ['∟90*56*5', '90', '56', '5', '9', '1.680947'],
      ['∟90*56*6', '90', '56', '6', '9', '1.997091'], ['∟90*56*7', '90', '56', '7', '9', '2.320285'],
      ['∟90*56*8', '90', '56', '8', '9', '2.818131'], ['∟100*63*6', '100', '63', '6', '10', '1.988338'],
      ['∟100*63*7', '100', '63', '7', '10', '2.411214'], ['∟100*63*8', '100', '63', '8', '10', '2.852987'],
      ['∟100*63*10', '100', '63', '10', '10', '3.234983'], ['∟100*80*6', '100', '80', '6', '10', '1.867718'],
      ['∟100*80*7', '100', '80', '7', '10', '2.411214'], ['∟100*80*8', '100', '80', '8', '10', '2.852987'],
      ['∟100*80*10', '100', '80', '10', '10', '3.234983'], ['∟110*70*6', '110', '70', '6', '10', '1.867718'],
      ['∟110*70*7', '110', '70', '7', '10', '2.411214'], ['∟110*70*8', '110', '70', '8', '10', '2.852987'],
      ['∟110*70*10', '110', '70', '10', '10', '3.234983'], ['∟125*80*7', '125', '80', '7', '11', '2.164728'],
      ['∟125*80*8', '125', '80', '8', '11', '2.647948'], ['∟125*80*10', '125', '80', '10', '11', '3.415083'],
      ['∟125*80*12', '125', '80', '12', '11', '70.033464'], ['∟140*90*8', '140', '90', '8', '12', '2.623685'],
      ['∟140*90*10', '140', '90', '10', '12', '3.396304'], ['∟140*90*12', '140', '90', '12', '12', '4.023189'],
      ['∟140*90*14', '140', '90', '14', '12', '4.564779'], ['∟150*90*8', '150', '90', '8', '12', '2.623685'],
      ['∟150*90*10', '150', '90', '10', '12', '15.623477'], ['∟150*90*12', '150', '90', '12', '12', '4.023189'],
      ['∟150*90*14', '150', '90', '14', '12', '4.564779'], ['∟150*90*15', '150', '90', '15', '12', '5.048601'],
      ['∟150*90*16', '150', '90', '16', '12', '5.273894'], ['∟160*100*10', '160', '100', '10', '13', '3.175121'],
      ['∟160*100*12', '160', '100', '12', '13', '4.130150'], ['∟160*100*14', '160', '100', '14', '13', '4.659324'],
      ['∟160*100*16', '160', '100', '16', '13', '5.355936'], ['∟180*110*10', '180', '110', '10', '14', '3.457382'],
      ['∟180*110*12', '180', '110', '12', '14', '4.074881'], ['∟180*110*14', '180', '110', '14', '14', '4.610403'],
      ['∟180*110*16', '180', '110', '16', '14', '5.313432'], ['∟200*125*12', '200', '125', '12', '14', '4.074881'],
      ['∟200*125*14', '200', '125', '14', '14', '4.610403'], ['∟200*125*16', '200', '125', '16', '14', '5.313432'],
      ['∟200*125*18', '200', '125', '18', '14', '5.933743']]

fang = [[str(_) + '*' + str(_), str(_)] for _ in range(3, 50)]

ju = [[str(_) + '*' + str(_ + 1), str(_), str(_ + 1)] for _ in range(3, 50)]

guan = [['Φ' + str(_) + 'mm', str(_)] for _ in range(3, 50)]

fa = [[str(_ + 1) + '*' + str(_), str(_ + 1), str(_)] for _ in range(3, 50)]

c0_all = [cao, gong, H, ban, jin, deng, bu, fang, ju, guan, fa]
c0 = ['槽钢', '工字钢', 'H型钢',
      '钢板、扁钢', '钢筋、圆钢',
      '等边角钢', '不等边角钢',
      '方管', '矩管', '钢管', '法兰盘']
file_path = dirname(__file__) + '/'


class MainWindow(QMainWindow):
    def __init__(self):
        super(MainWindow, self).__init__()
        loadUi(file_path + 'windows.ui', self)
        self.c0_n, self.c1_n, self.c2_n, self.c3_n, self.save_num = 0, 0, 0, 0, 3
        self.c0.currentIndexChanged.connect(self.selection_c0)
        self.c1.highlighted.connect(self.selection_c1)
        self.c1.currentIndexChanged.connect(self.selection_c1)
        self.c2.highlighted.connect(self.selection_c2)
        self.c3.highlighted.connect(self.selection_c3)
        [_.editingFinished.connect(self.run) for _ in
         [self.row, self.air, self.h, self.w, self.d, self.t, self.r1, self.r2, self.lon, self.num]]
        self.b0.pressed.connect(self.run)
        self.start()

    def start(self):
        self.c0.addItems(c0)
        self.c2.addItems(['m', 'mm'])
        self.c3.addItems([str(_) for _ in range(self.save_num, 11)])
        self.selection_c0(self.c0_n)
        self.selection_c1(self.c1_n)
        self.selection_c2(self.c2_n)
        self.selection_c3(self.c3_n)

    def selection_c0(self, c0_n):
        self.c0_n = c0_n
        self.c1.clear()
        self.c1.addItems([_[0] for _ in c0_all[self.c0_n]])
        if self.c0_n == 0:
            self.plot.setPixmap(QPixmap(file_path + '图片/0槽钢.jpg'))
        elif self.c0_n == 1:
            self.plot.setPixmap(QPixmap(file_path + '图片/1工字钢.jpg'))
        elif self.c0_n == 2:
            self.plot.setPixmap(QPixmap(file_path + '图片/2H型钢.jpg'))
        elif self.c0_n == 3:
            self.plot.setPixmap(QPixmap(file_path + '图片/3钢板.jpg'))
        elif self.c0_n == 4:
            self.plot.setPixmap(QPixmap(file_path + '图片/4钢筋.jpg'))
        elif self.c0_n == 5:
            self.plot.setPixmap(QPixmap(file_path + '图片/5等边角钢.jpg'))
        elif self.c0_n == 6:
            self.plot.setPixmap(QPixmap(file_path + '图片/6不等边角钢.jpg'))
        elif self.c0_n == 7:
            self.plot.setPixmap(QPixmap(file_path + '图片/7方管.jpg'))
        elif self.c0_n == 8:
            self.plot.setPixmap(QPixmap(file_path + '图片/8矩管.jpg'))
        elif self.c0_n == 9:
            self.plot.setPixmap(QPixmap(file_path + '图片/9钢管.jpg'))
        elif self.c0_n == 10:
            self.plot.setPixmap(QPixmap(file_path + '图片/10法兰盘.jpg'))

    def selection_c1(self, c1_n):
        [_.setEnabled(True) for _ in [self.air, self.h, self.w, self.d, self.t, self.r1, self.r2, self.lon]]
        [_.clear() for _ in [self.air, self.h, self.w, self.d, self.t, self.r1, self.r2, self.s, self.p, self.z]]
        self.w40.setText('高度H:')
        self.w50.setText('宽度W:')
        self.w60.setText('腰宽D:')
        self.w70.setText('腿宽T:')
        self.w111.setText('根')
        self.c1_n = c1_n
        if self.c0_n == 0:
            self.air.setText('0.339')
            self.h.setText(c0_all[self.c0_n][self.c1_n][1])
            self.w.setText(c0_all[self.c0_n][self.c1_n][2])
            self.d.setText(c0_all[self.c0_n][self.c1_n][3])
            self.t.setText(c0_all[self.c0_n][self.c1_n][4])
            self.r1.setText(c0_all[self.c0_n][self.c1_n][5])
            self.r2.setText(c0_all[self.c0_n][self.c1_n][6])
        if self.c0_n == 1:
            self.air.setText('0.615')
            self.h.setText(c0_all[self.c0_n][self.c1_n][1])
            self.w.setText(c0_all[self.c0_n][self.c1_n][2])
            self.d.setText(c0_all[self.c0_n][self.c1_n][3])
            self.t.setText(c0_all[self.c0_n][self.c1_n][4])
            self.r1.setText(c0_all[self.c0_n][self.c1_n][5])
            self.r2.setText(c0_all[self.c0_n][self.c1_n][6])
        elif self.c0_n == 2:
            self.air.setText('0.858')
            self.h.setText(c0_all[self.c0_n][self.c1_n][1])
            self.w.setText(c0_all[self.c0_n][self.c1_n][2])
            self.d.setText(c0_all[self.c0_n][self.c1_n][3])
            self.t.setText(c0_all[self.c0_n][self.c1_n][4])
            self.r1.setText(c0_all[self.c0_n][self.c1_n][5])
            self.r2.setText('')
            self.w70.setText('厚度T:')
        elif self.c0_n == 3:
            self.air.setText('')
            self.h.setText(c0_all[self.c0_n][self.c1_n][1])
            self.w.setText('1000')
            self.d.setText('')
            self.t.setText('')
            self.r1.setText('')
            self.r2.setText('')
            self.w40.setText('厚度H:')
            self.w111.setText('张')
        elif self.c0_n == 4:
            self.air.setText('')
            self.h.setText('')
            self.w.setText('')
            self.d.setText(c0_all[self.c0_n][self.c1_n][1])
            self.t.setText('')
            self.r1.setText('')
            self.r2.setText('')
            self.w60.setText('直径D:')
        elif self.c0_n == 5:
            self.air.setText('0.215')
            self.h.setText('')
            self.w.setText(c0_all[self.c0_n][self.c1_n][1])
            self.d.setText(c0_all[self.c0_n][self.c1_n][2])
            self.t.setText('')
            self.r1.setText(c0_all[self.c0_n][self.c1_n][3])
            self.r2.setText(c0_all[self.c0_n][self.c1_n][4])
            self.w60.setText('厚度D:')
        elif self.c0_n == 6:
            self.air.setText('0.215')
            self.h.setText(c0_all[self.c0_n][self.c1_n][1])
            self.w.setText(c0_all[self.c0_n][self.c1_n][2])
            self.d.setText(c0_all[self.c0_n][self.c1_n][3])
            self.t.setText('')
            self.r1.setText(c0_all[self.c0_n][self.c1_n][4])
            self.r2.setText(c0_all[self.c0_n][self.c1_n][5])
            self.w60.setText('厚度D:')
        elif self.c0_n == 7:
            self.air.setText('')
            self.h.setText('')
            self.w.setText(c0_all[self.c0_n][self.c1_n][1])
            self.d.setText('1')
            self.t.setText('')
            self.r1.setText('')
            self.r2.setText('')
            self.w60.setText('壁厚D:')
        elif self.c0_n == 8:
            self.air.setText('')
            self.h.setText(c0_all[self.c0_n][self.c1_n][1])
            self.w.setText(c0_all[self.c0_n][self.c1_n][2])
            self.d.setText('1')
            self.t.setText('')
            self.r1.setText('')
            self.r2.setText('')
            self.w60.setText('壁厚D:')
        elif self.c0_n == 9:
            self.air.setText('')
            self.h.setText('')
            self.w.setText('')
            self.d.setText(c0_all[self.c0_n][self.c1_n][1])
            self.t.setText('1')
            self.r1.setText('')
            self.r2.setText('')
            self.w60.setText('外径D:')
            self.w70.setText('壁厚T:')
        elif self.c0_n == 10:
            self.air.setText('')
            self.h.setText('1')
            self.w.setText('')
            self.d.setText('')
            self.t.setText('')
            self.r1.setText(c0_all[self.c0_n][self.c1_n][1])
            self.r2.setText(c0_all[self.c0_n][self.c1_n][2])
            self.lon.setEnabled(False)
            self.w40.setText('厚度H:')
            self.w111.setText('张')
        [_.setEnabled(False) for _ in [self.air, self.h, self.w, self.d, self.t, self.r1, self.r2] if not _.text()]
        self.run()

    def selection_c2(self, c2_n):
        self.c2_n = c2_n
        self.run()

    def selection_c3(self, c3_n):
        self.c3_n = c3_n
        self.run()

    def run(self):
        try:
            row = float(self.row.text())
            lon = float(self.lon.text())
            num = float(self.num.text())
            if self.c0_n == 0:
                air = float(self.air.text())
                h = float(self.h.text())
                w = float(self.w.text())
                d = float(self.d.text())
                t = float(self.t.text())
                r1 = float(self.r1.text())
                r2 = float(self.r2.text())
                s = (h * d + 2 * t * (w - d) + air * (r1 ** 2 - r2 ** 2)) * 10 ** -2
                self.t0.setText(f'截面积 S = H*D+2*T*(W-D)+α*[(R1)²-(R2)²]/100\n'
                                f'S = {h}*{d}+2*{t}*({w}-{d})+{air}*[({r1})²-({r2})²]/100\n'
                                f'S = {s} C㎡\n'
                                f'单位重量 P = S*ρ/10\n'
                                f'P = {s}*{row}/10\n'
                                f'P = {s * row * pow(10, -1)} kg/m\n'
                                f'总重量 Z = P*L*N/{pow(10, 3 if self.c2_n == 0 else 6)}\n'
                                f'Z = {s * row * pow(10, -1)} * {lon} * {num}/{pow(10, 3 if self.c2_n == 0 else 6)}\n'
                                f'Z = {s * row * pow(10, -1) * lon * num * pow(10, -3 if self.c2_n == 0 else -6)} t')
            elif self.c0_n == 1:
                air = float(self.air.text())
                h = float(self.h.text())
                w = float(self.w.text())
                d = float(self.d.text())
                t = float(self.t.text())
                r1 = float(self.r1.text())
                r2 = float(self.r2.text())
                s = (h * d + 2 * t * (w - d) + air * (r1 ** 2 - r2 ** 2)) * 10 ** -2
                self.t0.setText(f'截面积 S = [H*D+2*T*(W-D)+α*[(R1)²-(R2)²]]/100\n'
                                f'S = [{h}*{d}+2*{t}*({w}-{d})+{air}*[({r1})²-({r2})²]]/100\n'
                                f'S = {s} C㎡\n'
                                f'单位重量 P = S*ρ/10\n'
                                f'P = {s}*{row}/10\n'
                                f'P = {s * row * pow(10, -1)} kg/m\n'
                                f'总重量 Z = P*L*N/{pow(10, 3 if self.c2_n == 0 else 6)}\n'
                                f'Z = {s * row * pow(10, -1)} * {lon} * {num}/{pow(10, 3 if self.c2_n == 0 else 6)}\n'
                                f'Z = {s * row * pow(10, -1) * lon * num * pow(10, -3 if self.c2_n == 0 else -6)} t')
            elif self.c0_n == 2:
                air = float(self.air.text())
                h = float(self.h.text())
                w = float(self.w.text())
                d = float(self.d.text())
                t = float(self.t.text())
                r1 = float(self.r1.text())
                s = (d * (h - 2 * t) + 2 * w * t + air * r1 ** 2) * 10 ** -2
                self.t0.setText(f'截面积 S = [D*(H-2*T)+2*W*T+α*(R1)²]/100\n'
                                f'S = [{d}*({h}-2*{t})+2*{w}*{t}+{air}*({r1})²]/100\n'
                                f'S = {s} C㎡\n'
                                f'单位重量 P = S*ρ/10\n'
                                f'P = {s}*{row}/10\n'
                                f'P = {s * row * pow(10, -1)} kg/m\n'
                                f'总重量 Z = P*L*N/{pow(10, 3 if self.c2_n == 0 else 6)}\n'
                                f'Z = {s * row * pow(10, -1)} * {lon} * {num}/{pow(10, 3 if self.c2_n == 0 else 6)}\n'
                                f'Z = {s * row * pow(10, -1) * lon * num * pow(10, -3 if self.c2_n == 0 else -6)} t')
            elif self.c0_n == 3:
                h = float(self.h.text())
                w = float(self.w.text())
                s = w * h * 10 ** -2
                self.t0.setText(f'截面积 S = H*W/100\n'
                                f'S = {h}*{w}/100\n'
                                f'S = {s} C㎡\n'
                                f'单位重量 P = S*ρ/10\n'
                                f'P = {s}*{row}/10\n'
                                f'P = {s * row * pow(10, -1)} kg/m\n'
                                f'总重量 Z = P*L*N/{pow(10, 3 if self.c2_n == 0 else 6)}\n'
                                f'Z = {s * row * pow(10, -1)} * {lon} * {num}/{pow(10, 3 if self.c2_n == 0 else 6)}\n'
                                f'Z = {s * row * pow(10, -1) * lon * num * pow(10, -3 if self.c2_n == 0 else -6)} t')
            elif self.c0_n == 4:
                d = float(self.d.text())
                s = pi * d ** 2 / 4 * 10 ** -2
                self.t0.setText(f'截面积 S = Π*D²/4/100\n'
                                f'S = {pi}*{d}²/4/100\n'
                                f'S = {s} C㎡\n'
                                f'单位重量 P = S*ρ/10\n'
                                f'P = {s}*{row}/10\n'
                                f'P = {s * row * pow(10, -1)} kg/m\n'
                                f'总重量 Z = P*L*N/{pow(10, 3 if self.c2_n == 0 else 6)}\n'
                                f'Z = {s * row * pow(10, -1)} * {lon} * {num}/{pow(10, 3 if self.c2_n == 0 else 6)}\n'
                                f'Z = {s * row * pow(10, -1) * lon * num * pow(10, -3 if self.c2_n == 0 else -6)} t')
            elif self.c0_n == 5:
                air = float(self.air.text())
                w = float(self.w.text())
                d = float(self.d.text())
                r1 = float(self.r1.text())
                r2 = float(self.r2.text())
                s = (d * (2 * w - d) + air * (r1 ** 2 - 2 * r2 ** 2)) * 10 ** -2
                self.t0.setText(f'截面积 S = [D*(2*W-D)+α*[(R1)²-(R2)²]]/100\n'
                                f'S = [{d}*(2*{w}-{d})+{air}*({r1}²-{r2}²)]/100\n'
                                f'S = {s} C㎡\n'
                                f'单位重量 P = S*ρ/10\n'
                                f'P = {s}*{row}/10\n'
                                f'P = {s * row * pow(10, -1)} kg/m\n'
                                f'总重量 Z = P*L*N/{pow(10, 3 if self.c2_n == 0 else 6)}\n'
                                f'Z = {s * row * pow(10, -1)} * {lon} * {num}/{pow(10, 3 if self.c2_n == 0 else 6)}\n'
                                f'Z = {s * row * pow(10, -1) * lon * num * pow(10, -3 if self.c2_n == 0 else -6)} t')
            elif self.c0_n == 6:
                air = float(self.air.text())
                h = float(self.h.text())
                w = float(self.w.text())
                d = float(self.d.text())
                r1 = float(self.r1.text())
                r2 = float(self.r2.text())
                s = (d * (h + w - d) + air * (r1 ** 2 - 2 * r2 ** 2)) * 10 ** -2
                self.t0.setText(f'截面积 S = [D*(H+W-D)+α*[(R1)²-(R2)²]]/100\n'
                                f'S = [{d}*({h}+{w}-{d})+{air}*({r1}²-{r2}²)]/100\n'
                                f'S = {s} C㎡\n'
                                f'单位重量 P = S*ρ/10\n'
                                f'P = {s}*{row}/10\n'
                                f'P = {s * row * pow(10, -1)} kg/m\n'
                                f'总重量 Z = P*L*N/{pow(10, 3 if self.c2_n == 0 else 6)}\n'
                                f'Z = {s * row * pow(10, -1)} * {lon} * {num}/{pow(10, 3 if self.c2_n == 0 else 6)}\n'
                                f'Z = {s * row * pow(10, -1) * lon * num * pow(10, -3 if self.c2_n == 0 else -6)} t')
            elif self.c0_n == 7:
                w = float(self.w.text())
                d = float(self.d.text())
                s = 4 * d * (w - d) * 10 ** -2
                self.t0.setText(f'截面积 S = [4*D*(W-D)]/100\n'
                                f'S = [4*{d}*({w}-{d})]/100\n'
                                f'S = {s} C㎡\n'
                                f'单位重量 P = S*ρ/10\n'
                                f'P = {s}*{row}/10\n'
                                f'P = {s * row * pow(10, -1)} kg/m\n'
                                f'总重量 Z = P*L*N/{pow(10, 3 if self.c2_n == 0 else 6)}\n'
                                f'Z = {s * row * pow(10, -1)} * {lon} * {num}/{pow(10, 3 if self.c2_n == 0 else 6)}\n'
                                f'Z = {s * row * pow(10, -1) * lon * num * pow(10, -3 if self.c2_n == 0 else -6)} t')
            elif self.c0_n == 8:
                h = float(self.h.text())
                w = float(self.w.text())
                d = float(self.d.text())
                s = (2 * d * (w - d) + 2 * d * (h - d)) * 10 ** -2
                self.t0.setText(f'截面积 S = [2*D*(W-D)+2*D*(H-D)]/100\n'
                                f'S = [2*{d}*({w}-{d})+2*{d}*({h}-{d})]/100\n'
                                f'S = {s} C㎡\n'
                                f'单位重量 P = S*ρ/10\n'
                                f'P = {s}*{row}/10\n'
                                f'P = {s * row * pow(10, -1)} kg/m\n'
                                f'总重量 Z = P*L*N/{pow(10, 3 if self.c2_n == 0 else 6)}\n'
                                f'Z = {s * row * pow(10, -1)} * {lon} * {num}/{pow(10, 3 if self.c2_n == 0 else 6)}\n'
                                f'Z = {s * row * pow(10, -1) * lon * num * pow(10, -3 if self.c2_n == 0 else -6)} t')
            elif self.c0_n == 9:
                d = float(self.d.text())
                t = float(self.t.text())
                s = pi * ((d / 2) ** 2 - (d / 2-t) ** 2) * 10 ** -2
                self.t0.setText(f'截面积 S = [Π*[(D/2)²-(D/2-T)²]]/100\n'
                                f'S = [{pi}*[({d}/2)²-({d}/2-{t})²]]/100\n'
                                f'S = {s} C㎡\n'
                                f'单位重量 P = S*ρ/10\n'
                                f'P = {s}*{row}/10\n'
                                f'P = {s * row * pow(10, -1)} kg/m\n'
                                f'总重量 Z = P*L*N/{pow(10, 3 if self.c2_n == 0 else 6)}\n'
                                f'Z = {s * row * pow(10, -1)} * {lon} * {num}/{pow(10, 3 if self.c2_n == 0 else 6)}\n'
                                f'Z = {s * row * pow(10, -1) * lon * num * pow(10, -3 if self.c2_n == 0 else -6)} t')
            elif self.c0_n == 10:
                lon = float(self.h.text())
                r1 = float(self.r1.text())
                r2 = float(self.r2.text())
                s = (pi * r1 ** 2 - pi * r2 ** 2) * 10 ** -2
                self.t0.setText(f'截面积 S = [Π*(R1)²-Π*(R2)²]/100\n'
                                f'S = [{pi}*{r1}²-{pi}*{r2}²]/100\n'
                                f'S = {s} C㎡\n'
                                f'单位重量 P = S*ρ/10\n'
                                f'P = {s}*{row}/10\n'
                                f'P = {s * row * pow(10, -1)} kg/m\n'
                                f'总重量 Z = P*H*N/{pow(10, 3 if self.c2_n == 0 else 6)}\n'
                                f'Z = {s * row * pow(10, -1)} * {lon} * {num}/{pow(10, 3 if self.c2_n == 0 else 6)}\n'
                                f'Z = {s * row * pow(10, -1) * lon * num * pow(10, -3 if self.c2_n == 0 else -6)} t')
            else:
                s = 1
            p = s * row * pow(10, -1)
            z = p * lon * num * pow(10, -3 if self.c2_n == 0 else -6)
            self.s.setText(str(round(s, int(self.c3_n + self.save_num))))
            self.p.setText(str(round(p, int(self.c3_n + self.save_num))))
            self.z.setText(str(round(z, int(self.c3_n + self.save_num))))
        except:
            [_.clear() for _ in [self.s, self.p, self.z]]
            QMessageBox.information(self, '警告', '输入有误，请更正！', QMessageBox.Yes)


if __name__ == "__main__":
    app = QApplication([])
    window = MainWindow()
    window.show()
    app.exec_()
